# -*- coding:utf-8 -*-
"""
@Time : 2021/1/18 00:03
@Author: langengel
@Des: 公共模块
"""

def rule_tree(data, pid):
    """
    权限层级遍历
    :param data: rule[]
    :param pid: 父ID
    :return: list
    """
    result = []
    for item in data:
        if pid == item["pId"]:
            temp = rule_tree(data, item["id"])
            if len(temp) > 0:
                item["children"] = temp
            result.append(item)
    return result
